import { setTailWindcss } from './tailwindcss';
import setupElementPlus from './elementui';
import setupPinia from './pinia';
import { App } from 'vue';
import _ from 'lodash';
export function setPlugins(app: App) {
  setTailWindcss();
  autoRegisterComponent(app);
  setupElementPlus(app);
  setupPinia(app);
}

// 自动注册全局组件
function autoRegisterComponent(app: App) {
  const components = import.meta.globEager('../components/form/*.vue');
  Object.keys(components).forEach(key => {
    const name = key.split('/').pop()?.split('.').shift() as string;
    app.component(_.upperFirst(_.camelCase(name)), components[key].default);
  });
}
